package com.seednia.foundation.framework.extension;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

import com.seednia.foundation.framework.service.ServiceContainer;

/**
 * Loads the ServiceContainer 
 * @author Young Suk Ahn
 *
 */
public class InitAppListener implements ApplicationListener<ContextRefreshedEvent> {

	private static final Log logger = LogFactory.getLog(InitAppListener.class);
	
	@Override
	public void onApplicationEvent(ContextRefreshedEvent ctxEvent) {
		
		int numServices = ServiceContainer.getInstance().loadServices(ctxEvent.getApplicationContext());
		logger.info("Loaded "+numServices+" services");
	}

}
